package com.note.chh.notebook.Uitls;

import android.content.Context;
import android.os.Handler;

import com.qmuiteam.qmui.widget.dialog.QMUITipDialog;

/**
 * Created by caihuahui on 2018/1/9.
 */

public class TipUtils {

    //默认2秒后关闭
    public static void tipNormal(Context Context,String content){
        final QMUITipDialog tipDialog = new QMUITipDialog.Builder(Context)
                .setTipWord(content)
                .create();
        tipDialog.show();
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                tipDialog.dismiss();
            }
        }, 2000);
    }
    //自己定义几秒后关闭
    public static void tipTime(Context Context,String content,int second){
        final QMUITipDialog tipDialog = new QMUITipDialog.Builder(Context)
                .setTipWord(content)
                .create();
        tipDialog.show();
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                tipDialog.dismiss();
            }
        }, second*1000);
    }
    //成功提示
    public static void tipSuccess(Context Context,String content){
        final QMUITipDialog  tipDialog = new QMUITipDialog.Builder(Context)
                .setIconType(QMUITipDialog.Builder.ICON_TYPE_SUCCESS)
                .setTipWord(content)
                .create();
        tipDialog.show();
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                tipDialog.dismiss();
            }
        }, 2000);
    }
    //失败提示
    public static void tipError(Context Context,String content){
        final QMUITipDialog  tipDialog = new QMUITipDialog.Builder(Context)
                .setIconType(QMUITipDialog.Builder.ICON_TYPE_FAIL)
                .setTipWord(content)
                .create();
        tipDialog.show();
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                tipDialog.dismiss();
            }
        }, 2000);
    }
    //警告提示
    public static void tipWarning(Context Context,String content){
        final QMUITipDialog  tipDialog = new QMUITipDialog.Builder(Context)
                .setIconType(QMUITipDialog.Builder.ICON_TYPE_INFO)
                .setTipWord(content)
                .create();
        tipDialog.show();
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                tipDialog.dismiss();
            }
        }, 2000);
    }
    //---------------------------------------------------------------------------//
    private static QMUITipDialog mtipDialog;
    //加载中动画
    public static void tipLoading(Context Context,String content){
        if (mtipDialog!=null&&mtipDialog.isShowing()) {
            mtipDialog.dismiss();
        }
        mtipDialog = new QMUITipDialog.Builder(Context)
                .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING)
                .setTipWord(content)
                .create();
        mtipDialog.show();
    }
    //关闭加载中的动画
    public static void tipColseLoading(){
        if (mtipDialog!=null&&mtipDialog.isShowing()) {
            mtipDialog.dismiss();
        }
    }

}
